<template>
	<exception>
		<view class="container">
			123
			<image class="img" src="../../static/logo.png"></image>
			<button type="default" @tap="linkTo('/pages/test2/test2')">跳转pages/test2</button>
			<button type="default" @tap="linkTo('/pagesA/test3/test3')">跳转pagesA/test3</button>
			<button type="default" @tap="linkTo('/pagesB/test4/test4')">跳转pagesB/test4</button>
			<button type="primary" style="margin-top:80px;" @tap="userLogout">退出登录</button>
		</view>
	</exception>
</template>

<script>
	import demo from '@/components/logic/index/demo.vue'
	import {mapState, mapActions, mapGetters} from 'vuex'
	import {getUserInfo, userLogout} from '@/service/user_serv.js'
	export default {
		components: {
			demo
		},
		data() {
			return {
				title: 'Hello',
				datetime: new Date().getTime(),
				info: {}
			}
		},
		computed: {
			...mapGetters({
				isTokenValid: 'user/isTokenValid'
			}),
		},
		onLoad() {
			console.log(this.isTokenValid)
			if(!this.isTokenValid){
				this.$r.reLaunch('/pages/login/login')
				return;
			}
			const res = getUserInfo().then(res => {
				this.$logger(res, '用户信息')
			})
			
		},
		methods: {
			...mapActions(['user/userLogout']),
			userLogout() {
				this['user/userLogout']()
				this.$r.reLaunch('/pages/login/login')
			},
			linkTo(url){
				this.$r.push(url)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.img{
		@include imageSize(80rpx, 80rpx);
	}
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
